let app = getApp();

Component({
  externalClasses: ['custom-class'],
  properties: {
    list: {
      type: Array,
      value: [
        {
          text: '首页',
          iconPath: '/ws_micro_shop_guide/common/images/home.png',
          selectedIconPath: '/ws_micro_shop_guide/common/images/home_on.png',
          path: '/ws_micro_shop_guide/pages/index/index',
        },
        {
          text: '分享',
          iconPath: '/ws_micro_shop_guide/common/images/fenxiang.png',
          selectedIconPath: '/ws_micro_shop_guide/common/images/fenxiang_on.png',
          path: '/ws_micro_shop_guide/pages/achieve-maintain/index',
        },
        {
          text: '客户',
          iconPath: '/ws_micro_shop_guide/common/images/user.png',
          selectedIconPath: '/ws_micro_shop_guide/common/images/user_on.png',
          path: '/ws_micro_shop_guide/pages/management/list/list',
        },
      ],
    },
    current: {
      type: Number,
      value: 0,
    },
  },
  ready() {
    let rtPage = '/' + this.getCurrentPageUrl();
    this.setData({
      rtPage,
    });
  },
  methods: {
    getCurrentPageUrl() {
      let pages = getCurrentPages();
      let currentPage = pages[pages.length - 1];
      let url = currentPage.route;
      return url;
    },
    tabChange(e) {
      let { url: targetUrl } = e.currentTarget.dataset;
      let { rtPage } = this.data;
      if (targetUrl === rtPage) return;
      app.util.navigateTo(targetUrl, {}, true);
    },
  },
});
